home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / sos3-2.lha / src / agg / Association_scp.c < prev    next >
C/C++ Source or Header  |  1992-01-23  |  3KB  |  79 lines

  1. #line 1 "/fzi/prost/stone/SOS3-2/src/agg/Association.c"
  2. /* --------------------------------------------------------------------------
  3.  * Copyright 1992 by Forschungszentrum Informatik (FZI)
  4.  *
  5.  * You can use and distribute this software under the terms of the licence
  6.  * you should have received along with this program.
  7.  * If not or if you want additional information, write to
  8.  * Forschungszentrum Informatik, "STONE", Haid-und-Neu-Strasse 10-14,
  9.  * D-7500 Karlsruhe 1, Germany.
  10.  * --------------------------------------------------------------------------
  11.  */
  12. // **************************************************************************
  13. // Module Association                06/09/90                Juergen Uhl (ju)
  14. //
  15. // **************************************************************************
  16. // implements methods of classes: Association
  17. // **************************************************************************
  18.  
  19. #include "sys.h"
  20. #include "agg_err.h"
  21. #include "trc_agg.h"
  22.  
  23. #include "agg_sos.h"
  24.  
  25. // **************************************************************************
  26. sos_Bool _sos_Object_sos_Object_Association::is_role1 (sos_Typed_id &_tpid,sos_Object o)
  27. // **************************************************************************
  28. {
  29.    // The function tests if an object is an element of the aggregate.
  30.    // The test may be based on equality or identity, depending on
  31.    // the value of the "role1_based_on_equal" attribute.
  32.  
  33.    T_PROC ("sos_Object_sos_Object_Association::is_role1");
  34.    TT (agg_H, T_ENTER);
  35.  
  36.    sos_Bool result = FALSE;
  37.    sos_Object_sos_Object_Association a = sos_Object_sos_Object_Association::make(_tpid,this);
  38.    sos_Bool based_on_equal = sos_Object_sos_Object_Association::make(_tpid,this).get_role1_based_on_equal();
  39.  
  40.    agg_iterate_association (a, sos_Object role1, sos_Object role2)
  41.    {  if (agg_same_entity (o, role1, based_on_equal, EQ_STRONG))
  42.       {  result = TRUE;
  43.      break;
  44.       }
  45.    }
  46.    agg_iterate_association_end (a, role1, role2);
  47.  
  48.    TT (agg_H, T_LEAVE);
  49.    return result;
  50. } // ** is_role1 **
  51.  
  52. // **************************************************************************
  53. sos_Bool _sos_Object_sos_Object_Association::is_role2 (sos_Typed_id &_tpid,sos_Object o)
  54. // **************************************************************************
  55. {
  56.    // The function tests if an object is an element of the aggregate.
  57.    // The test may be based on equality or identity, depending on
  58.    // the value of the "role2_based_on_equal" attribute.
  59.  
  60.    T_PROC ("sos_Object_sos_Object_Association::is_role2");
  61.    TT (agg_H, T_ENTER);
  62.  
  63.    sos_Bool result = FALSE;
  64.    sos_Object_sos_Object_Association a = sos_Object_sos_Object_Association::make(_tpid,this);
  65.    sos_Bool based_on_equal = sos_Object_sos_Object_Association::make(_tpid,this).get_role2_based_on_equal();
  66.  
  67.    agg_iterate_association (a, sos_Object role1, sos_Object role2)
  68.    {  if (agg_same_entity (o, role2, based_on_equal, EQ_STRONG))
  69.       {  result = TRUE;
  70.      break;
  71.       }
  72.    }
  73.    agg_iterate_association_end (a, role1, role2);
  74.  
  75.    TT (agg_H, T_LEAVE);
  76.  
  77.    return result;
  78. } // ** is_role2 **
  79.